package com.project.application.server.system.controller;

import com.project.application.common.constant.Constants;
import com.project.application.framework.security.LoginBody;
import com.project.application.framework.security.service.SysLoginService;
import com.project.application.framework.web.controller.BaseController;
import com.project.application.framework.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author :levnli
 */
@RestController
@Api(tags = {"登录"})
public class SysLoginController extends BaseController {

    @Autowired
    private SysLoginService loginService;

    /**
     * 登录方法
     *
     * @param loginBody 登录信息
     * @return 结果
     */
    @PostMapping("/login")
    @ApiOperation("登录")
    public AjaxResult login(@RequestBody @Validated LoginBody loginBody) {
        AjaxResult ajax = AjaxResult.success();
        ajax.put(Constants.TOKEN, loginService.login(loginBody));
        return ajax;
    }

}
